教學來源:
MDC-111 Android: Incorporating Material Components into your codebase (Kotlin)
整理:
1 不太相關的問題:
ArrayAdapter requires the resource ID to be a TextView” xml problems
arrayadapter主要用來執行只有一個textview,如果要處理不只一個textview或有imageview,用arrayadapter就很麻煩,然後建議用RecyclerView
If you are considering using array adapter with a ListView, consider using RecyclerView instead. RecyclerView offers similar features with better performance and more flexibility than ListView provides
第2個的回答:
ArrayAdapter adapter = new ArrayAdapter<String>(this, R.layout.listitem,R.id.textview, countryArray);
2 問題:Scrollview can host only one direct child [duplicate]
scroll view要在全部東西的外層再放一個layout,像這樣:
參考:Android Beginner Tutorial #13 - ScrollViews [Scrolling Layouts]
3 更改android studio的顏色:
4
Change font of the floating label EditText and TextInputLayout
想要改變字體的話,要自己製作.ttf檔。但是只改變字的大小和顏色,不用這麼麻煩。
帳密畫面可以用TextInputLayout:
參考:https://gist.github.com/mitchtabian/6233773419c67307a20bac55ead77a02
Login Layout (Part 17) - [Build an Instagram Clone]
練習:
來源:
How to change the size of the EditText hint in TextInputLayout
1 改floating label(在框線上的文字)
一 用app:hintTextAppearance="@style/xxx " 屬性
二 在style檔案裡自訂文字大小:
<style name="TextLabel" parent="TextAppearance.Design.Hint">
<item name="android:textSize">44dp</item>
</style>
2 更改畫面的addr,比較麻煩,要用客製的TextInputLayout:
(因為是private helper class,所以沒有內建的xml可以更改)
The size of the regular hint text is set to the EditText's text size when that is added to the TextInputLayout during inflation/initialization. This value is ultimately set on a private helper class in TextInputLayout, and there is no publicly exposed method or field to change it.
照個第一篇解答的步驟:(有些步驟跳過,直接看第一篇解答)
一 創建TextInputLayout類別檔
二 創建一個resource資源檔(attrs.xml)
<resources>
<declare-styleable name="CustomTextInputLayout" >
<attr name="mainHintTextSize" format="dimension" />
</declare-styleable>
</resources>
三 app:mainHintTextSize="100sp" 就可以了
3 橘色框線: app:boxStrokeColor="#FF9800"
4 輸入框(com.google.android.material.textfield.TextInputEditText)的字體大小:
android:textAppearance
5 除了TextInputLayout一開始的文字要客製化,,其他好像都有內建的可以改,輸入關鍵字color,就可以看到有很多顏色可以改:
6 還有一個不能改
沒被選擇的框線顏色(unfocus border):
Issue: change border color or box stroke for unfocused TextInputLayout in android
解決方法:解答1
目前測試:
顏色可以更改(color.xml),改全部的TextInputLayout,但是框線寬度(style.xml)好像沒有改到
color.xml增加:
<color name="mtrl_textinput_default_box_stroke_color">#00A600</color>